package com.higgins.eventtracking.client.datamaintenance;

import java.util.Date;
import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.higgins.eventtracking.client.EventTrackingService;
import com.higgins.eventtracking.client.EventTrackingServiceAsync;
import com.higgins.eventtracking.client.FinanceTrackingService;
import com.higgins.eventtracking.client.FinanceTrackingServiceAsync;
import com.higgins.eventtracking.client.SecurityAccessDeniedException;
import com.higgins.eventtracking.client.dto.DynamicTypeDTO;
import com.higgins.eventtracking.client.dto.HealthEventDTO;
import com.higgins.eventtracking.client.dto.TimeTableTaskDTO;


public class MaintainHealthEventTab extends VerticalPanel	{
	private boolean firstRun = true;
	private final TextBox healthEventTypeTextBox = new TextBox();
	private final CheckBox clearNullsCheckBox = new CheckBox("Clear Nulls?");
	private final Label numberOfHealthEventText = new Label("Number of Health Events:");
	private final Label numberOfHealthEvents = new Label("0");
	private final Button numberOfHealthEventsButton = new Button("Check No. Health Events");
	private final Button listHealthEventsButton = new Button("List Health Events");
	private final Button addDynamicExerciseTypes = new Button("add Dynamic Exercise Types");
	private final Button addDynamicFramesOfMind = new Button("add Dynamic Frames of Mind");
	private final Button addDynamicExperience = new Button("add Dynamic Experience");
	private final Button addDynamicMeals = new Button("add Dynamic Meals");
	private final Button addDynamicSubTypes = new Button("add Dynamic Sub Types");
	private final Button addEvidenceTypes = new Button("add Evidence Types");
	private final Button addTopLevelTypes = new Button("add Top Level Types");
    private final Button updateRules = new Button("updateRules");
    private final Label updateRuleLabel = new Label();
    private final Button addMentalHealthTypes = new Button("add Mental Health Types");
    private final Button addAdventuresAndInterestsTypes = new Button("add Adventures And Interests Types");
    private final Button addNewTimeTableEntry = new Button("add New Time Table Entry");
    private final Button addNewTimeTableEntry2 = new Button("add New Time Table Entry 2");
	
	private final DataMaintenanceServiceAsync dataMaintenanceService = GWT
										.create(DataMaintenanceService.class);
	private final FinanceTrackingServiceAsync financeTrackingService = GWT
										.create(FinanceTrackingService.class);
	private final EventTrackingServiceAsync greetingsService = GWT
	                                    .create(EventTrackingService.class);

	
	private final VerticalPanel backGround = this;
	
	public MaintainHealthEventTab()	{	}
	
	public void update()	{
		if (firstRun)	
			initialise();
	}
	public void initialise()	{
		populateTabPanel();
		firstRun = false;
	}
	public void populateTabPanel()	{
		add(healthEventTypeTextBox);
		add(clearNullsCheckBox);
		add(numberOfHealthEventText);
		add(numberOfHealthEvents);
		add(numberOfHealthEventsButton);
		add(listHealthEventsButton);
		add(addDynamicExerciseTypes);
		add(addDynamicFramesOfMind);
		add(addDynamicExperience);
		add(addDynamicMeals);
		add(addDynamicSubTypes);
		add(addEvidenceTypes);
		add(addTopLevelTypes);
		add(updateRules);
		add(updateRuleLabel);
		add(addMentalHealthTypes);
		add(addAdventuresAndInterestsTypes);
        add(addNewTimeTableEntry);
        add(addNewTimeTableEntry2);
		numberOfHealthEventsButton.addClickHandler(new ClickHandler(){

			@Override
			public void onClick(ClickEvent event) {
				dataMaintenanceService.retrieveNumberofHealthEvents(healthEventTypeTextBox.getText(), clearNullsCheckBox.getValue(), new AsyncCallback<Integer>() {

					@Override
					public void onFailure(Throwable caught) {
						numberOfHealthEvents.setText("Error!! " + caught.toString());
					}

					@Override
					public void onSuccess(Integer result) {
						numberOfHealthEvents.setText(result!=null?result.toString():"Error");
					}  });
			} });
		listHealthEventsButton.addClickHandler(new ClickHandler(){

			@Override
			public void onClick(ClickEvent event) {
				dataMaintenanceService.listHealthEventDTOs(healthEventTypeTextBox.getText(), clearNullsCheckBox.getValue(), new AsyncCallback<List<HealthEventDTO>>() {

					@Override
					public void onFailure(Throwable caught) {
						numberOfHealthEvents.setText("Error!! " + caught.toString());
					}

					@Override
					public void onSuccess(List<HealthEventDTO> result) {
						int count = 0;
						for (HealthEventDTO dto:result)	{
							numberOfHealthEvents.setText("" +(count++));
							backGround.add(new Label("" 
									+ checkForNull(dto.getHealthEventType()) + "; "
									+ checkForNull(dto.getDescription()) + "; " 
									+ checkForNull(dto.getHealthEventIntensityScale()) + "; " 
									+ checkForNull(dto.getHealthEventFrameOfMind()) + "; "
									+ checkForNull(dto.getTimestamp()) + "; "
							));
						}
					}  });
			} });
		
		addDynamicExerciseTypes.addClickHandler(new ClickHandler()  {

			@Override
			public void onClick(ClickEvent event) {
				DynamicTypeDTO dto = null;
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Cardio");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 1");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 2");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 3");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Daily");		
				addDynamicType(dto);

				
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Cardio");		
				dto.setSubType(true);
				dto.setSubCategory("Walking");
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Cardio");		
				dto.setSubType(true);
				dto.setSubCategory("Cycling");
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Cardio");		
				dto.setSubType(true);
				dto.setSubCategory("Running");
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Cardio");		
				dto.setSubType(true);
				dto.setSubCategory("Swimming");			
				addDynamicType(dto);

				
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 1");		
				dto.setSubType(true);
				dto.setSubCategory("Delts Vertical");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 1");		
				dto.setSubType(true);
				dto.setSubCategory("Delts Butterfly");		
				addDynamicType(dto);
			
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 1");		
				dto.setSubType(true);
				dto.setSubCategory("Triceps Exts");		
				addDynamicType(dto);
				
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 2");		
				dto.setSubType(true);
				dto.setSubCategory("Squats");		
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 2");		
				dto.setSubType(true);
				dto.setSubCategory("Leg Extension");
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 2");		
				dto.setSubType(true);
				dto.setSubCategory("Leg Curls");
				addDynamicType(dto);
				
				
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 3");		
				dto.setSubType(true);
				dto.setSubCategory("Dumbell Rows");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Group 3");		
				dto.setSubType(true);
				dto.setSubCategory("Bicep Curls");		
				addDynamicType(dto);
				

				
				

				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Daily");		
				dto.setSubType(true);
				dto.setSubCategory("Abs");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Daily");		
				dto.setSubType(true);
				dto.setSubCategory("Neck");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Daily");		
				dto.setSubType(true);
				dto.setSubCategory("Upper Forearm");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Daily");		
				dto.setSubType(true);
				dto.setSubCategory("Lower Forearm");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Daily");		
				dto.setSubType(true);
				dto.setSubCategory("Calfs");		
				addDynamicType(dto);
				


				
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Inactive");		
				dto.setSubType(true);
				dto.setSubCategory("Obliques");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Inactive");		
				dto.setSubType(true);
				dto.setSubCategory("Bench Press");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Inactive");
				dto.setSubType(true);
				dto.setSubCategory("Lower Back");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Inactive");		
				dto.setSubType(true);
				dto.setSubCategory("Upper Back");		
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Inactive");		
				dto.setSubType(true);
				dto.setSubCategory("Deadlifts");		
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Inactive");		
				dto.setSubType(true);
				dto.setSubCategory("Delts Rear");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Inactive");		
				dto.setSubType(true);
				dto.setSubCategory("Ab Twists");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Inactive");		
				dto.setSubType(true);
				dto.setSubCategory("Pull-overs");		
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExerciseType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Inactive");		
				dto.setSubType(true);
				dto.setSubCategory("Stretching");
				addDynamicType(dto);
				
			}  } );
	
		addDynamicFramesOfMind.addClickHandler(new ClickHandler()  {
	
			@Override
			public void onClick(ClickEvent event) {
				DynamicTypeDTO dto = null;

				dto = new DynamicTypeDTO();
				dto.setCategory("FrameOfMindType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("House Keeping");				
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("FrameOfMindType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Build For The Future");				
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("FrameOfMindType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Legal Career");				
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("FrameOfMindType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Current Career");				
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("FrameOfMindType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Relax");				
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("FrameOfMindType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Relationship");				
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("FrameOfMindType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Social");				
				addDynamicType(dto);
				
			}  } );
		
		addDynamicExperience.addClickHandler(new ClickHandler()  {
			
			@Override
			public void onClick(ClickEvent event) {
				DynamicTypeDTO dto = null;
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExperienceType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Software");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("ExperienceType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Finance");				
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("ExperienceType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Commercial Awareness");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("ExperienceType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Commercial Law");				
				addDynamicType(dto);
			}  } );
		
		addDynamicMeals.addClickHandler(new ClickHandler()  {
			
			@Override
			public void onClick(ClickEvent event) {
				DynamicTypeDTO dto = null;
				
				dto = new DynamicTypeDTO();
				dto.setCategory("MealType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Breakfast");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("MealType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Lunch");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("MealType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Dinner");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("MealType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Vegetables");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("MealType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Take Away");				
				addDynamicType(dto);

				

			}  } );		
		
		addDynamicSubTypes.addClickHandler(new ClickHandler()  {
			
			@Override
			public void onClick(ClickEvent event) {
				DynamicTypeDTO dto = null;
				
				dto = new DynamicTypeDTO();
				dto.setCategory("FrameOfMindType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Current Career");		
				dto.setSubType(true);
				dto.setSubCategory("Software");
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("FrameOfMindType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Current Career");				
				dto.setSubType(true);
				dto.setSubCategory("Finance");
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("FrameOfMindType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Current Career");				
				dto.setSubType(true);
				dto.setSubCategory("Commercial Awareness");
				addDynamicType(dto);

			}  } );		
		
		addEvidenceTypes.addClickHandler(new ClickHandler()  {
			
			@Override
			public void onClick(ClickEvent event) {
				DynamicTypeDTO dto = null;
				
				dto = new DynamicTypeDTO();
				dto.setCategory("EvidenceType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Current Career");		
				dto.setSubType(false);
				addDynamicType(dto);

			}  } );		

		addTopLevelTypes.addClickHandler(new ClickHandler()  {
			
			@Override
			public void onClick(ClickEvent event) {
				DynamicTypeDTO dto = null;

				dto = new DynamicTypeDTO();
				dto.setCategory("TopLevelType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Fuel");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("TopLevelType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Planning");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("TopLevelType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Body");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("TopLevelType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Knowledge");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("TopLevelType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Knowledge");		
				dto.setSubType(true);
				dto.setSubCategory("Software Development");
				addDynamicType(dto);
				
				dto = new DynamicTypeDTO();
				dto.setCategory("TopLevelType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Urgent Tasks");				
				addDynamicType(dto);

				dto = new DynamicTypeDTO();
				dto.setCategory("TopLevelType");
				dto.setTimestamp(new Date());
				dto.setDynamicType("Investment");				
				addDynamicType(dto);

				
			}  } );		
		
		updateRules.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                // TODO Auto-generated method stub
                dataMaintenanceService.updateAllRules(new AsyncCallback<Integer>() {

                    @Override
                    public void onFailure(Throwable caught) {
                        // TODO Auto-generated method stub
                        
                    }

                    @Override
                    public void onSuccess(Integer result) {
                        updateRuleLabel.setText(result.toString());
                    } } );
            } } );
		
	      addMentalHealthTypes.addClickHandler(new ClickHandler()  {
	            
	            @Override
	            public void onClick(ClickEvent event) {
	                DynamicTypeDTO dto = null;
	                
	                dto = new DynamicTypeDTO();
	                dto.setCategory("MentalHealthType");
	                dto.setTimestamp(new Date());
	                dto.setDynamicType("Thought");       
	                dto.setSubType(false);
	                dto.setSubCategory(null);
	                addDynamicType(dto);

                    dto = new DynamicTypeDTO();
                    dto.setCategory("MentalHealthType");
                    dto.setTimestamp(new Date());
                    dto.setDynamicType("Feeling");       
                    dto.setSubType(false);
                    dto.setSubCategory(null);
                    addDynamicType(dto);

                    dto = new DynamicTypeDTO();
                    dto.setCategory("MentalHealthType");
                    dto.setTimestamp(new Date());
                    dto.setDynamicType("Problem");       
                    dto.setSubType(false);
                    dto.setSubCategory(null);
                    addDynamicType(dto);

                    dto = new DynamicTypeDTO();
                    dto.setCategory("MentalHealthType");
                    dto.setTimestamp(new Date());
                    dto.setDynamicType("Diary");       
                    dto.setSubType(false);
                    dto.setSubCategory(null);
                    addDynamicType(dto);

	            }  } );     
	      
	      addAdventuresAndInterestsTypes.addClickHandler(new ClickHandler()  {
              
              @Override
              public void onClick(ClickEvent event) {
                  DynamicTypeDTO dto = null;
                  
                  dto = new DynamicTypeDTO();
                  dto.setCategory("AdventuresType");
                  dto.setTimestamp(new Date());
                  dto.setDynamicType("Outdoors");       
                  dto.setSubType(false);
                  dto.setSubCategory(null);
                  addDynamicType(dto);

                  dto = new DynamicTypeDTO();
                  dto.setCategory("InterestsType");
                  dto.setTimestamp(new Date());
                  dto.setDynamicType("Economics");       
                  dto.setSubType(false);
                  dto.setSubCategory(null);
                  addDynamicType(dto);
              }  } );   
	      
	      addNewTimeTableEntry.addClickHandler(new ClickHandler()  {

            @Override
            public void onClick(ClickEvent event) {
                TimeTableTaskDTO dto = new TimeTableTaskDTO();
                dto.setDate(new Date());
                dto.setMonth(11);
                dto.setMonthYear(2013);
                dto.setTask("Research Masters");
                greetingsService.updateTimeTableTask(dto, new AsyncCallback<String>(){
                    @Override
                    public void onFailure(Throwable caught) {
                        System.out.println("Throw " + caught.toString());
                    }
                    @Override
                    public void onSuccess(String result) {
                        System.out.println("Success " + result);
                    } });
            }
	          
	      });
	      
          addNewTimeTableEntry2.addClickHandler(new ClickHandler()  {

              @Override
              public void onClick(ClickEvent event) {
                  TimeTableTaskDTO dto = new TimeTableTaskDTO();
                  dto.setDate(new Date());
                  dto.setWeek(1);
                  dto.setWeekYear(2013);
                  dto.setTask("Have a Holiday");
                  greetingsService.updateTimeTableTask(dto, new AsyncCallback<String>(){
                      @Override
                      public void onFailure(Throwable caught) {
                          System.out.println("Throw " + caught.toString());
                      }
                      @Override
                      public void onSuccess(String result) {
                          System.out.println("Success " + result);
                      } });
              }
                
            });	      
		
	}
	
	private void addDynamicType(DynamicTypeDTO dto)	{
		try {
			financeTrackingService.updateDynamicType(dto, new AsyncCallback<String>() {

				@Override
				public void onFailure(Throwable caught) {
					
				}

				@Override
				public void onSuccess(String result) {
					
				}  });
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityAccessDeniedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	private String checkForNull(String text)	{
		if (text!=null)	{
			return text;
		}
		return "null";
	}
	private String checkForNull(Date text)	{
		if (text!=null)	{
			return text.toString();
		}
		return "null";
	}
	private String checkForNull(Integer text)	{
		if (text!=null)	{
			return text.toString();
		}
		return "null";
	}
}
